{% extends 'base.html.twig' %}
{% import 'Import/app_import.html.twig' as appImport %}

{% block head_title %}{{ 'enrich'|trans }} - {{ policy.name }}{% endblock %}

{% block heading_1 %}
    {{ appImport.heading({'level': 1, 'title': 'enrich'|trans, 'link': {'url': path('enrich')}}) }}
{% endblock %}

{% block heading_2 %}
    {{ appImport.heading({'level': 2, 'title': policy.name}) }}
{% endblock %}

{% block tabs %}
    {% include 'Modules/enrich/enrich_read_tabs.html.twig' with {'active': 'summary'} %}
{% endblock %}

{% block main_content %}
    {% embed 'Embed/block_embed.html.twig' %}
        {% import 'Import/app_import.html.twig' as appImport %}
        {% block content %}
            {{ appImport.heading({'level': 3, 'title': 'summary'|trans}) }}

            {% embed 'Embed/buttons_embed.html.twig' %}
                {% import 'Import/app_import.html.twig' as appImport %}
                {% block content %}
                    {% if is_granted('ENRICH_POLICY_DELETE', policy) %}
                        {{ appImport.buttonModal({
                            'id': 'PolicyDelete',
                            'title': 'delete'|trans,
                            'body': policy.name,
                            'href': path('enrich_delete', {'name': policy.name}),
                        }) }}
                    {% endif %}

                    {% if is_granted('ENRICH_POLICY_EXECUTE', policy) %}
                        {{ appImport.buttonModal({
                            'id': 'PolicyExecute',
                            'title': 'execute'|trans,
                            'body': policy.name,
                            'href': path('enrich_execute', {'name': policy.name}),
                        }) }}
                    {% endif %}

                    {% if is_granted('ENRICH_POLICY_COPY', policy) %}
                        <a class="btn btn-primary btn-sm" href="{{ path('enrich_create', {'policy': policy.name}) }}">{{ 'copy'|trans }}</a>
                    {% endif %}
                {% endblock %}
            {% endembed %}

            <p>
                <strong>{{ 'type'|trans }}</strong><br>
                {{ policy.type }}
            </p>

            {% if policy.indices %}
                <p>
                    <strong>{{ 'indices'|trans }}</strong><br>
                    {{ policy.indices|join(', ') }}
                </p>
            {% endif %}

            <p>
                <strong>{{ 'match_field'|trans }}</strong><br>
                {{ policy.matchField }}
            </p>

            {% if policy.enrichFields %}
                <p>
                    <strong>{{ 'enrich_fields'|trans }}</strong><br>
                    {{ policy.enrichFields|join(', ') }}
                </p>
            {% endif %}

            {% if policy.query %}
                <p>
                    <strong>{{ 'query'|trans }}</strong><br>
                    {{ policy.query }}
                </p>
            {% endif %}
        {% endblock %}
    {% endembed %}
{% endblock %}
